<!--#include file="../appInit.aspx"-->
<!--#include file="../_user/appDocs.aspx"-->
<%

  // 配置当前目录的域名
  AppConfig.CurDomain = AppConfig.Domain + "/" + AppConfig.DirDocs;

  lblArtDetails.Text = LblArtDetails();

  lblBreadcrumb.Text = LblBreadcrumb();
  lblTitle.Text = LblTitle();
  lblStatTitle.Text = Regex.Replace( lblTitle.Text,"'","\\'");
  lblStatItemID.Text= Request.QueryString["id"];
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><asp:literal id="lblTitle" runat="server"></asp:literal> -- 饮食健康网</title>
<style>
  @import "css/layout.css";
 #breadCrumb{margin-top:15px;}
 #cnt_l{border:1px solid #ccc;width:635px;float:left;padding:10px;font:14px/25px "宋体",Arial,sans-serif;}
 #cnt_l p{margin-bottom:10px;}
 #cnt_r{width:300px;float:right;}
 #article_tit{padding:10px;font-size:20px;font-weight:bold;text-align:center;}
 #art_from{margin:10px;border-top:1px solid #dedede;border-bottom:1px solid #dedede;line-height:30px;text-align:center;}
 #art_from span{margin-right:10px;}
 #art_from .c a{color:#ff0000;}
 #article_cnt p{text-indent:2em;}
 #ad_rows{float:left;width:200px;height:230px;padding:5px;margin-right:5px;border:1px solid #be0000;}
 #post{width:620px;padding:5px;border:1px solid #dedede;}
 #post input{width:300px;padding:1px;}
 #post textarea{width:500px;height:180px;}
 #post label{float:left;}
</style>
<script type="text/javascript" src="../js/jquery.pack.js"></script>
<script type="text/javascript" src="../js/myjslib.js"></script>
</head>
<body>
  <div id="container">
    <div id="header">
        <!--#include file="inc.header.aspx"-->
        <div id="intro">
          <div id="breadCrumb" class="left">
            您现在的位置：<asp:literal id="lblBreadcrumb" runat="server"></asp:literal><!--品味生活 > 新闻中心 > 正文-->
          </div>
          <div id="search" class="right">
            <form action="<%=AppConfig.Domain%>/search.aspx" method="GET">
                <input type="text" name="keywords" value="" >
                <input type="submit" class="button" value="" >
            </form>
          </div>
        </div>
    </div>
    <div id="cnt_main">
      <div id="cnt_l">

        <asp:literal id="lblArtDetails" runat="server"></asp:literal>

        <!--
        <div id="article_tit">
          今日最新菜式：小鸡炖蘑菇
        </div>
        <div id="art_from">
          <span class="c"><a href="http://www.themz.cn">http://www.themz.cn</a></span><span>2009年04月02日06:28</span>
          <span>中国新闻网</span><span class="c"><a href="#">我要评论(332)</a></span>
        </div>
        <div id="article_cnt">
          content here
        </div>
        -->
        <div class="clear2"></div>
        <div id="post">
          <p><b>评论内容</b></p>
          <div class="comments"><!--评论列表--></div>
          <p><a name="comment"><b>填写评论</b></a></p>
          <!--<p>现在有<strong>5514</strong>人对本文发表评论<span>查看所有评论</span></p>-->
          <form class="frm" method="post" action="/appLoadEx.aspx?cmd=docs/cmt/add">
               <input type="hidden" name="catId" value="<%=Request.QueryString["id"]%>" />
            <p><label for="name">姓名：</label><input type="text" id="name" name="author" value="游客" /></p>
            <p><label for="rows">内容：</label><textarea id="rows" name="content"></textarea></p>
            <p><label for="validate">验证码：</label>
               <input type="text" name="MyValidateCode" style="width:60px" />
               <img id="valiImg" src="../images/ValidateCode.aspx" style="vertical-align:-0.8em;*vertical-align:-0.5em;border:none" />
               <a href="javascript:document.getElementById('valiImg').src='../images/ValidateCode.aspx?'+new Date;void(0);">刷新</a>
            </p>
            <p><label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="submit" value="提交" /></p>
          </form>
        </div>
      </div>
      <div id="cnt_r">
        <div>
            <!--#include file="ad/google_300X250_pic.aspx"-->
        </div>
      </div>
    </div>
    <div class="clear"></div>
    <div id="footer">
        <!--#include file="inc.footer.aspx"-->
    </div>
  </div>



<script type="text/javascript">


 // 入口
 $(function(){
     var comment = new Comments("#post",".comments",".frm");
 });

(function($){

    // 构造函数
    // frameID包含listID,formID,这些ID可以是class或标签,但是要确保唯一性
    // frameID全局唯一,listID,formID平级,在frameID内唯一
    // formID必须是<form>标签的标识
    // 例如
    // <div id="frameID">
    //     <div  class=listID"></div>
    //     <form class="formID"></form>
    // </div>
    var Comments = window.Comments = function(frameID,listID,formID)
    {
        // 载入框架
        this.frame = $(frameID);
        this.list  = this.frame.find(listID);        //评论列表
        this.frm   = this.frame.find(formID);        //评论表单

        this.get_list( this.list );   // 监听显示
        this.submit_add( this.frm );  // 监听提交
    }

    // list方法
    Comments.prototype.get_list = function( objShow )
    {
        var a = location.hash.split('/');

        var curPage = a[a.length-1] || 1;
        var id = <%=Request.QueryString["id"]%>;

        // 读取数据
        var _ = this;
        var httpReq = $.getJSON( "/appLoad.aspx?cmd=docs/cmt/list&catId="+id+"&page="+curPage+"&pageSize=5&time="+new Date(), function(json){
            var s = "";
            if( json.error ){
                s += '<p>'+json.error +'</p>';
            }else if( json.list ){
                var list = json.list;
                if( list.id ){
                    for( var i=0; i<list.id.length; i++ ){
                        s += '  <div>';
                        s += '    <p class="left"> <strong>' + $.htmlEncode(list.author[i])+'</strong> <span>['+list.createTime[i]+']</span></p>';
                        s += '  </div><div class="clear"></div>';
                        s += '  <div>';
                        s += '    <p><span>'+list.content[i]+'</span></p>';
                        s += '  </div>';
                    }
                    s +=  '<div id="ajaxPageNav" class="green-black">' + $.pageNav( json.page.RecordCount, json.page.PageCount, json.page.CurrentPage,"blog/cmt/list/"+id ) +'</div>';

                }else{
                    s += '<p>该文章目前还没有评论!</p>';
                }
            }

            objShow.empty().append( s );
            _.page_nav();  // 监听分页导航
        });
    }

    // submit_comment 方法
    Comments.prototype.submit_add = function( frm )
    {
        var _ = this;
        frm.submit( function(){
            $.ajax({
                async: false,
                cache: false,
                timeout: 20000,
                type: "POST",
                contentType:"application/x-www-form-urlencoded",

                url: $(this).attr("action"),
                data:$(this).serialize(),
                dataType: "json",

                //complete:function(dat){alert(dat);},
                success:function(json){
                     if(json.error){
                        alert(json.error);
                     }else if( json.success ){
                         alert(json.success);
                     }else{
                        alert("未知的返回信息!");
                    }
                    _.get_list(_.list);
                },
                error: function(dat){ alert(dat + ": Error, 发生了错误");  }
            });
            return false;
        });

    };

    // page_nav 方法
    Comments.prototype.page_nav = function()
    {
        _ = this;
        $("#ajaxPageNav a").click(function(ev)
        {
          if( 0 == ev.button || 1 == ev.button )  // 只监听左键, 0是ff的左键,1是ie左键
          {
              var tag = ev.target;
              location.hash = tag.hash;
              _.get_list(_.list);
              return false;
          }
        });
    }

})(jQuery);

</script>

<script type="text/javascript">
    pcryl_stat_clientID = '10000';
    pcryl_stat_itemID   = '<asp:literal id="lblStatItemID" runat="server"></asp:literal>';
    pcryl_stat_title    = '<asp:literal id="lblStatTitle"  runat="server"></asp:literal>';
</script>
<script type="text/javascript" src="http://localhost/statistics/collecting.js"></script>


</body>
</html>